import face_recognition
from PIL import Image, ImageDraw
from pprint import pprint

# 将图片加载到Numpy数组
# image = face_recognition.load_image_file("../img/ag.png")
image = face_recognition.load_image_file("../img/women.jpg")

# 查找图像中所有面部的所有面部特征
face_landmark_list = face_recognition.face_landmarks(image)
facial_features = [
    'chin',
    'left_eyebrow',
    'right_eyebrow',
    'nose_bridge',
    'nose_tip',
    'left_eye',
    'right_eye',
    'top_lip',
    'bottom_lip'
]

pil_image = Image.fromarray(image)
pprint(face_landmark_list)
for face_landmarks in face_landmark_list:
    # print(face_landmarks)
    # pil_image = Image.fromarray(image)
    d = ImageDraw.Draw(pil_image)
    for facial_feature in facial_features:
        print(face_landmarks[facial_feature])
        d.line(face_landmarks[facial_feature], fill=(255, 255, 255), width=3)
pil_image.show()

